package com.bang.study.day01.list;

import java.util.Arrays;
import java.util.Iterator;

/**
 * @Auther: Bang
 * @Date: 2019/9/9 0009 18:22
 * @Description:
 */
public class MyArrayList<E> implements Iterator<E> {


    private static final int DEFAULT_CAPACITY = 10;


    private int theSize;


    private E[] theItems;


    public MyArrayList() {

        doClear();
    }

    public int size() {
        return theSize;
    }

    public boolean isEmpty() {
        return size() == 0;
    }

    public void trimToSize() {
        ensureCapacity(size());
    }

    private void doClear() {
        theSize = 0;
        ensureCapacity(DEFAULT_CAPACITY);
    }

    private void ensureCapacity(int newCapacity) {
        if (newCapacity <theSize) {
            return;
        }
        E[] old = theItems;
        theItems = (E[]) new Object[newCapacity];
        for (int i = 0; i <size(); i++) {
            theItems[i] = old[i];
            
        }

    }

    @Override
    public boolean hasNext() {
        return false;
    }


    @Override
    public E next() {
        return null;
    }


    @Override
    public void remove() {

    }

}
